package com.example.webfluxr2dbcdemo.service;

import com.example.webfluxr2dbcdemo.bean.AdVo;
import com.example.webfluxr2dbcdemo.repository.AdRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

/**
 * @Author: zhangQi
 * @Date: 2020-09-30 16:54
 */
@Service
public class AdServiceImpl {
    @Autowired
    private AdRepository adRepository;

    public Flux<AdVo> findAll(){
        return adRepository.findAll().map(
                adBean -> AdVo.builder()
                .name(adBean.getName())
                .build()
        );
    }
}
